package br.com.monitor.videos;


/**
 *
 * @author Projeto Monitor - Smart Fit
 */

import java.awt.Component;
import java.awt.Dimension;
import java.io.IOException;
import java.net.URL;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.media.CannotRealizeException;
import javax.media.Manager;
import javax.media.NoPlayerException;
import javax.media.Player;

//</editor-fold>

/**
 *
 * @author Projeto Monitor
 */
import java.awt.Component;
import java.awt.Dimension;
import java.io.IOException;
import java.net.URL;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.media.CannotRealizeException;
import javax.media.Manager;
import javax.media.NoPlayerException;
import javax.media.Player;

//</editor-fold>

/**
 *
 * @author Eder
 */
public class Reprodutor extends javax.swing.JPanel {
    private Player mediaPlayer;
    private Component video;
    public Reprodutor(URL url, Dimension d){
        try{
        Manager.setHint(Manager.LIGHTWEIGHT_RENDERER, true);
        mediaPlayer = Manager.createRealizedPlayer(url);
        video = mediaPlayer.getVisualComponent();
        video.setSize(d);
        video.setVisible(true);
        add(video);
        
        } catch (IOException ex) {
            Logger.getLogger(Reprodutor.class.getName()).log(Level.SEVERE, null, ex);
        } catch (NoPlayerException ex){
            Logger.getLogger(Reprodutor.class.getName()).log(Level.SEVERE, null, ex);
        
        }catch (CannotRealizeException ex){
             Logger.getLogger(Reprodutor.class.getName()).log(Level.SEVERE, null, ex);
            
        }
    }
    
    public float getvolume(){
        return mediaPlayer.getGainControl().getLevel();
        
    }
    public void setvolume(float volume){
            mediaPlayer.getGainControl().setLevel(volume);
    }
    public void MUTE(){
        if(mediaPlayer.getGainControl().getMute()){
            mediaPlayer.getGainControl().setMute(false);
        }else{
            mediaPlayer.getGainControl().setMute(true);
        }
    }
    
    public void STOP(){
        mediaPlayer.stop();
        video.hide();
    }
    public void PLAY(){
        mediaPlayer.start();
        video.show();
    }
}
